// 练习题1
var fp = require('lodash/fp')
// 练习1
let islastInStock = fp.flowRight(fp.prop('in_stock'), fp.last)

// 练习2
let islastInStock2 = fp.flowRight(fp.prop('name'), fp.first)
const name = islastInStock2(cars)

//练习3
let _average = function (xs) {
  return fp.reduce(fp.add, 0, xs) / xs.length
}
let averageDollarValue = fp.flowRight(_average, fp.map(e => e.dollar_value))

// 练习4
let _underscore = fp.replace(/\W+/g, '_')

let sanitizNames = fp.flowRight(fp.map(_underscore), fp.map(fp.toLower), fp.map(e => e.name))  

let sanitizNames2 = fp.map(fp.flowRight(_underscore, fp.toLower, e => e.name))
